
import { createRouter,createWebHashHistory} from "vue-router";
import Home from '../components/Home'

const routes = [
  {
    path: '/',
    redirect: '/home',
    component: Home
  },
  {
    // home页面并不需要被访问，只是作为其它组件的父组件
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'AppIndex',
        component: () => import('../components/home/AppIndex')
      },
      {
        path: '/jotter',
        name: 'Jotter',
        component: () => import('../components/jotter/Articles')
      },
      {
        path: '/jotter/article',
        name: 'Article',
        component: () => import('../components/jotter/ArticleDetails')
      },
  //     {
  //       path: '/admin/content/editor',
  //       name: 'Editor',
  //       component: () => import('../components/admin/content/ArticleEditor'),
  //       meta: {
  //         requireAuth: true
  //       }
  //     },
      {
        path: '/library',
        name: 'Library',
        component: () => import('../components/library/LibraryIndex')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../components/Login')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../components/Register')
  },
  {
    path: '/admin',
    name: 'Admin',
    component: () => import('../components/admin/AdminIndex'),
    meta: {
      requireAuth: true
    },
    children: [
      {
        path: '/admin/dashboard',
        name: 'Dashboard',
        component: () => import('../components/admin/dashboard/admin/index'),
        meta: {
          requireAuth: true
        }
      }
    ]
  },

]


export  const  router = createRouter({
  history: createWebHashHistory(),
  routes
})

